package org.jeecg.util;


import org.activiti.engine.RepositoryService;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.TaskService;

/**
 * @Description: TODO
 * @author: huangjinbo
 * @date: 2021年06月21日 11:12
 */
public class ActivitiBeanUtil {

    private static TaskService taskService;
    private static RuntimeService runtimeService;
    private static RepositoryService repositoryService;

    static {//手动注入bean
        if (taskService == null) {
            try {
                taskService = (TaskService) SpringContextUtil.getBean(Class.forName("org.activiti.engine.TaskService"));
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            }
        }
        if (runtimeService == null) {
            try {
                runtimeService = (RuntimeService) SpringContextUtil.getBean(Class.forName("org.activiti.engine.RuntimeService"));
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            }
        }
        if (repositoryService == null) {
            try {
                repositoryService = (RepositoryService) SpringContextUtil.getBean(Class.forName("org.activiti.engine.RepositoryService"));
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            }
        }
    }


    public static TaskService getTaskService() {
        return taskService;
    }

    public static RuntimeService getRuntimeService() {
        return runtimeService;
    }

    public static RepositoryService getRepositoryService() {
        return repositoryService;
    }
}
